/*
 * generate by table-builder.Don't modify it
 */
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;


namespace CfgTable
{
    public partial class TbCfgHeroFateTrajectory
    {
        private readonly Dictionary<int, CfgHeroFateTrajectory> _dataMap;
        private readonly List<CfgHeroFateTrajectory> _dataList;

        /// <summary>
        /// HeorId和Stage联合索引map(key1:HeorId, Key2:Stage, value:Id)
        /// </summary>
        public IReadOnlyDictionary<int, IReadOnlyDictionary<int, int>> heroIdStageMap { get; private set; }
        /// <summary>
        /// 按HeroId和GroupId作为key的Id列表
        /// </summary>
        public IReadOnlyDictionary<int, IReadOnlyDictionary<int, IReadOnlyList<int>>> heroIdGroupIdList { get; private set; }

        public TbCfgHeroFateTrajectory(ByteBuf _buf)
        {
            //first read common data
            _TbCommonHeroFateTrajectory _commonData = null;
            var commonSize = _buf.ReadSize();
            if (commonSize > 0)
            {
                _commonData = new _TbCommonHeroFateTrajectory(_buf);
            }

            //then read row data
            var size = _buf.ReadSize();
            _dataMap = new Dictionary<int, CfgHeroFateTrajectory>(size * 3 / 2);
            _dataList = new List<CfgHeroFateTrajectory>(size);

            for (int i = 0; i < size; i++)
            {
                CfgHeroFateTrajectory _v;
                _v = CfgHeroFateTrajectory.DeserializeCfgHeroFateTrajectory(_buf, _commonData);
                _dataList.Add(_v);
                _dataMap.Add(_v.Id, _v);
            }

            // read extra fields 
            { int __n0 = _buf.ReadSize(); var __f0 = new Dictionary<int, IReadOnlyDictionary<int, int>> (__n0 * 3 / 2); heroIdStageMap = __f0 ; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ) { int __k0; __k0 = _buf.ReadInt(); IReadOnlyDictionary<int, int> __v0; { int __n1 = _buf.ReadSize(); var __f1 = new Dictionary<int, int> (__n1 * 3 / 2); __v0 = __f1 ; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ) { int __k1; __k1 = _buf.ReadInt(); int __v1; __v1 = _buf.ReadInt(); __f1.Add(__k1, __v1); } } __f0.Add(__k0, __v0); } }
            { int __n0 = _buf.ReadSize(); var __f0 = new Dictionary<int, IReadOnlyDictionary<int, IReadOnlyList<int>>> (__n0 * 3 / 2); heroIdGroupIdList = __f0 ; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ) { int __k0; __k0 = _buf.ReadInt(); IReadOnlyDictionary<int, IReadOnlyList<int>> __v0; { int __n1 = _buf.ReadSize(); var __f1 = new Dictionary<int, IReadOnlyList<int>> (__n1 * 3 / 2); __v0 = __f1 ; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ) { int __k1; __k1 = _buf.ReadInt(); IReadOnlyList<int> __v1; { int __n2 = _buf.ReadSize(); var __f2 = new int[__n2]; __v1 = __f2; for (var __i2 = 0 ; __i2 < __n2 ; __i2++ ){ int __v2; __v2 = _buf.ReadInt(); __f2[__i2] = __v2;} } __f1.Add(__k1, __v1); } } __f0.Add(__k0, __v0); } }

            PostInit();
        }

        public IReadOnlyDictionary<int, CfgHeroFateTrajectory> DataMap => _dataMap;
        public IReadOnlyList<CfgHeroFateTrajectory> DataList => _dataList;

        public CfgHeroFateTrajectory Get(int key)
        {
            if (_dataMap.TryGetValue(key, out var v))
            {
                return v;
            }
            IQIGame.Onigao.Framework.LogGame.LogError("[TbCfgHeroFateTrajectory] config not found,id:" + key.ToString());

            return null;
        }

        public CfgHeroFateTrajectory GetWithoutError(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;

        /// <summary>
        /// table data file
        /// </summary>
        public static string TableFileName { get; } = "herofatetrajectory";

        /// <summary>
        /// load table function
        /// </summary>
        public static TbCfgHeroFateTrajectory LoadFromFunc(System.Func<string, ByteBuf> loadFunc)
        {
            return new TbCfgHeroFateTrajectory(loadFunc(TableFileName));
        }

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();

    }

    public partial class CfgHeroFateTrajectory
    {
        private CfgHeroFateTrajectory(ByteBuf _buf, _TbCommonHeroFateTrajectory _commonData)
        {
            Id = _buf.ReadInt();
            HeroId = _buf.ReadInt();
            GroupId = _buf.ReadInt();
            Stage = _buf.ReadInt();
            Name = TableCenter.GetI18NText(_buf.ReadInt());
            { int dataIndex = _buf.ReadInt() - 1; Cost = _commonData._field0[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; GoldCost = _commonData._field1[dataIndex]; }
            NeedHeroLevel = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; AttType = _commonData._field2[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; AttValue = _commonData._field3[dataIndex]; }

            PostInit();
        }

        internal static CfgHeroFateTrajectory DeserializeCfgHeroFateTrajectory(ByteBuf _buf, _TbCommonHeroFateTrajectory _commonData)
        {
            return new CfgHeroFateTrajectory(_buf, _commonData);
        }

        /// <summary>
        /// major key
        /// </summary>
        public int Id { get; private set; }

        /// <summary>
        /// 英雄id
        /// </summary>
        public int HeroId { get; private set; }
        /// <summary>
        /// 所属缘轨章节
        /// </summary>
        public int GroupId { get; private set; }
        /// <summary>
        /// 缘轨阶段
        /// </summary>
        public int Stage { get; private set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; private set; }
        /// <summary>
        /// 激活本节点消耗道具的id|数量
        /// </summary>
        public IReadOnlyList<int> Cost { get; private set; }
        /// <summary>
        /// 激活本节点消耗货币的id|数量
        /// </summary>
        public IReadOnlyList<int> GoldCost { get; private set; }
        /// <summary>
        /// 激活要求英雄等级
        /// </summary>
        public int NeedHeroLevel { get; private set; }
        /// <summary>
        /// 节点属性1类型
        /// </summary>
        public IReadOnlyList<int> AttType { get; private set; }
        /// <summary>
        /// 节点属性1增值
        /// </summary>
        public IReadOnlyList<int> AttValue { get; private set; }


        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();
    }

    /// <summary>
    /// internal common data.Optimize memory
    /// </summary>
    internal class _TbCommonHeroFateTrajectory
    {

        internal IReadOnlyList<IReadOnlyList<int>> _field0 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field1 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field2 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field3 { get; private set; }
        internal _TbCommonHeroFateTrajectory(ByteBuf _buf)
        {
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field0 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field1 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field2 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field3 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
        }

    }
}
